package com.smec.remes.module.submit.adapter;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.smec.moblie.BR;
import com.smec.moblie.R;
import com.smec.moblie.databinding.ItemLogBinding;
import com.smec.remes.base.SmecBaseRecyclerViewHolder;
import com.smec.remes.bean.SmecLogBean;

import java.util.ArrayList;

/**
 * Created by xupeizuo on 2018/2/28.
 */

public class SmecLogAdapter extends RecyclerView.Adapter<SmecBaseRecyclerViewHolder> {

    private ArrayList<SmecLogBean> arrayList=new ArrayList<>();
    private Context mContext;

    public SmecLogAdapter(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public SmecBaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        ItemLogBinding itemLogBinding= DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.item_log,parent,false);
        SmecBaseRecyclerViewHolder smecBaseRecyclerViewHolder=new SmecBaseRecyclerViewHolder(itemLogBinding.getRoot());
        smecBaseRecyclerViewHolder.setViewType(viewType);
        smecBaseRecyclerViewHolder.setBinding(itemLogBinding);
        return smecBaseRecyclerViewHolder;
    }

    @Override
    public void onBindViewHolder(SmecBaseRecyclerViewHolder holder, int position) {
        ItemLogBinding itemLogBinding=(ItemLogBinding)holder.getBinding();
        itemLogBinding.setVariable(BR.log,arrayList.get(position));
    }

    @Override
    public int getItemCount() {
        return arrayList.size();
    }

    public void setArrayList(ArrayList<SmecLogBean> arrayList) {
        this.arrayList = arrayList;
        notifyDataSetChanged();
    }
}
